package com.ybu.config;

import com.ybu.handler.TokenInterceptorHandler;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ProjectName: cmall-ybu
 * @Titile: TokenHandlerConfig
 * @Author: Lucky
 * @Description: 注册token拦截器
 */
@SpringBootConfiguration //配置类
public class TokenHandlerConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenInterceptorHandler())
                .addPathPatterns("/api/**") //拦截url
                .excludePathPatterns("/api/user/login","/api/user/reg")// 放行注册和登录
                .excludePathPatterns("/api/product/**","api/category/**");//放行商品相关
    }
}